#ifndef EXPANDABLECARD_H
#define EXPANDABLECARD_H

#include "ElaLineEdit.h"
#include "ElaText.h"
#include <qcoreevent.h>
#include "ElaPushButton.h"
#include "ElaWidget.h"
#include <QWidget>
#include <QToolButton>
#include <QPropertyAnimation>

class ExpandableCard : public QWidget {
    Q_OBJECT
public:
    explicit ExpandableCard(const QString &time,
                            const QString &region,
                            const QString &content,
                            QWidget *parent = nullptr);
    QWidget *_content;
    ElaLineEdit *contentEdit;
    ElaLineEdit *zoneEdit;
    ElaText *timeLabel;
    ElaText *analysisLabel;
signals:
    void signaleditEnable();
    void signaleditDisable();
protected:
    bool eventFilter(QObject *obj, QEvent *event) override {
        if (obj == regionLabel && event->type() == QEvent::MouseButtonDblClick) {
            // 进入编辑模式
            startEditing();
            return true;
        }
    }
private slots:
    void toggle();
    void startEditing();
    void editEnable();
    void editDisable();

private:
    void setupContent(const QString &time, const QString &region);
    ElaText *regionLabel;
    ElaPushButton *_arrowButton;
    QPropertyAnimation *_animation;
    bool isExpanded;
};

#endif // EXPANDABLECARD_H
